//
//  RegisterView.swift
//  ShiZhe
//
//  Created by 陈卿伟 on 16/8/29.
//  Copyright © 2016年 陈卿伟. All rights reserved.
//

import UIKit

class RegisterView: UIView {
    
    var phoneNumber:UITextField!//电话号码输入框
    var password:UITextField!//密码输入框
    var passwordTwo:UITextField!//再次密码
    var nextButton:UIButton!//下一步按钮
    var protocolLabel:UILabel!//协议
    
    override init(frame: CGRect) {
        phoneNumber = UITextField()
        password = UITextField()
        passwordTwo = UITextField()
        nextButton = UIButton()
        protocolLabel = UILabel()
        super.init(frame: frame)
        self.createTextfield()
        self.createNextButton()
        self.createRegisterProtocol()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    
    override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {
        phoneNumber.resignFirstResponder()
        password.resignFirstResponder()
        passwordTwo.resignFirstResponder()
    }
    
    //创建电话号码  密码 再次密码输入框
    func createTextfield(){
        phoneNumber.frame = CGRect(x: 32*SCALEW, y: 27*SCALEH, width: 311*SCALEW, height: 39*SCALEH)
        phoneNumber.placeholder = "请输入手机号"
        phoneNumber.keyboardType = .NumberPad
        phoneNumber.font = BaseFunc.getSystemFont(14.5)
        phoneNumber.backgroundColor = UIColor.whiteColor()
        let view1 = UIView(frame: CGRect(x: 0,y: 0,width: 10,height: 1))
        phoneNumber.leftView = view1
        phoneNumber.leftViewMode = .Always
        phoneNumber.layer.borderWidth = 1
        phoneNumber.layer.borderColor = BaseFunc.createCustomColor(240, b: 240, g: 240, a: 1).CGColor
        phoneNumber.layer.cornerRadius = 5
        self.addSubview(phoneNumber)
        
        password.frame = CGRect(x: 32*SCALEW, y: 82*SCALEH, width: 311*SCALEW, height: 39*SCALEH)
        password.placeholder = "请输入密码"
        password.keyboardType = .Default
        password.font = BaseFunc.getSystemFont(14.5)
        password.backgroundColor = UIColor.whiteColor()
        let view2 = UIView(frame: CGRect(x: 0,y: 0,width: 10,height: 1))
        password.leftView = view2
        password.leftViewMode = .Always
        password.layer.borderWidth = 1
        password.layer.borderColor = BaseFunc.createCustomColor(240, b: 240, g: 240, a: 1).CGColor
        password.layer.cornerRadius = 5
        password.secureTextEntry = true
        self.addSubview(password)
        
        passwordTwo.frame = CGRect(x: 32*SCALEW, y: 137*SCALEH, width: 311*SCALEW, height: 39*SCALEH)
        passwordTwo.placeholder = "请再次输入密码"
        passwordTwo.keyboardType = .Default
        passwordTwo.font = BaseFunc.getSystemFont(14.5)
        passwordTwo.backgroundColor = UIColor.whiteColor()
        let view3 = UIView(frame: CGRect(x: 0,y: 0,width: 10,height: 1))
        passwordTwo.leftView = view3
        passwordTwo.leftViewMode = .Always
        passwordTwo.layer.borderWidth = 1
        passwordTwo.layer.borderColor = BaseFunc.createCustomColor(240, b: 240, g: 240, a: 1).CGColor
        passwordTwo.layer.cornerRadius = 5
        passwordTwo.secureTextEntry = true
        self.addSubview(passwordTwo)
    }
    
    
    //创建下一步按钮
    func createNextButton(){
        nextButton.frame = CGRect(x: 33*SCALEW, y: 200*SCALEH, width: 309*SCALEW, height: 50*SCALEH)
        nextButton.titleLabel?.font = BaseFunc.getCustomFont(18)
        nextButton.setTitle("下一步", forState: UIControlState())
        nextButton.backgroundColor = UIColor.blackColor()
        nextButton.layer.cornerRadius = 5
        self.addSubview(nextButton)
    }
    
    //协议和前面的说明文字
    func createRegisterProtocol(){
        let protocolExplainLabel = UILabel(frame: CGRect(x: 76*SCALEW,y: 270*SCALEH,width: 110*SCALEW,height: 16*SCALEH))
        protocolExplainLabel.text = "注册即表示您同意"
        protocolExplainLabel.textAlignment = .Left
        protocolExplainLabel.textColor = Theme.GrayColor
        protocolExplainLabel.font = BaseFunc.getSystemFont(13)
        self.addSubview(protocolExplainLabel)
        
        protocolLabel.frame = CGRect(x: 184*SCALEW, y: 270*SCALEH, width: 120*SCALEW, height: 16*SCALEH)
        protocolLabel.font = BaseFunc.getSystemFont(13)
        protocolLabel.textColor = Theme.BlueColor
        protocolLabel.text = "《三人行用户协议》"
        protocolLabel.textAlignment = .Center
        protocolLabel.userInteractionEnabled = true
        self.addSubview(protocolLabel)
    }
    
    
    
    
}


















